﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DslModeling = global::Microsoft.VisualStudio.Modeling;

namespace Mnow.MvvmLight.Tools.ViewModelDiagram
{
    public partial class ViewModelDiagramSerializationHelper
    {
        protected override void CheckVersion(DslModeling::SerializationContext serializationContext, global::System.Xml.XmlReader reader)
        {
            #region Check Parameters
            global::System.Diagnostics.Debug.Assert(serializationContext != null);
            if (serializationContext == null)
                throw new global::System.ArgumentNullException("serializationContext");
            global::System.Diagnostics.Debug.Assert(reader != null);
            if (reader == null)
                throw new global::System.ArgumentNullException("reader");
            #endregion

            global::System.Version expectedVersion_1_0_0_0 = new global::System.Version("1.0.0.0");
            global::System.Version expectedVersion_1_0_1_0 = new global::System.Version("1.0.1.0");
            global::System.Version expectedVersion_1_1_0_0 = new global::System.Version("1.1.0.0");
            global::System.Version expectedVersion_1_1_1_0 = new global::System.Version("1.1.1.0");
            global::System.Version expectedVersion_1_1_2_0 = new global::System.Version("1.1.2.0");
            global::System.Version expectedVersion_1_1_3_0 = new global::System.Version("1.1.3.0");
            global::System.Version expectedVersion_1_1_4_0 = new global::System.Version("1.1.4.0");
            string dslVersionStr = reader.GetAttribute("dslVersion");
            if (dslVersionStr != null)
            {
                try
                {
                    global::System.Version actualVersion = new global::System.Version(dslVersionStr);
                    if (actualVersion != expectedVersion_1_0_0_0 &&
                        actualVersion != expectedVersion_1_0_1_0 &&
                        actualVersion != expectedVersion_1_1_0_0 &&
                        actualVersion != expectedVersion_1_1_1_0 &&
                        actualVersion != expectedVersion_1_1_2_0 &&
                        actualVersion != expectedVersion_1_1_3_0 &&
                        actualVersion != expectedVersion_1_1_4_0)
                    {
                        ViewModelDiagramSerializationBehaviorSerializationMessages.VersionMismatch(serializationContext, reader, expectedVersion_1_1_3_0, actualVersion);
                    }
                }
                catch (global::System.ArgumentException)
                {
                    ViewModelDiagramSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
                }
                catch (global::System.FormatException)
                {
                    ViewModelDiagramSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
                }
                catch (global::System.OverflowException)
                {
                    ViewModelDiagramSerializationBehaviorSerializationMessages.InvalidPropertyValue(serializationContext, reader, "dslVersion", typeof(global::System.Version), dslVersionStr);
                }
            }
        }
    }
}
